<template>
	<view>
		<!-- <state0 v-if="orderForm.state == '待出库'" :id="id" :orderForm="orderForm" @update="update"></state0>
		<state1 v-if="orderForm.state == '已装车'" :id="id" :orderForm="orderForm" @update="update"></state1> -->
		<state2 v-if="orderForm.state == '已出库'" :orderId="id" :orderForm="orderForm" @update="update"></state2>
		<state3 v-if="orderForm.state == '已完结'" :orderId="id" :orderForm="orderForm" @update="update"></state3>
		<state4 v-if="orderForm.state == '已取消'" :orderId="id" :orderForm="orderForm" @update="update"></state4>
	</view>
</template>

<script>
	// import state0 from './components/state-0.vue'
	// import state1 from './components/state-1.vue'
	import state2 from './components/state-2.vue'
	import state3 from './components/state-3.vue'
	import state4 from './components/state-4.vue'
	
	export default {
		components:{
			// state0,
			// state1,
			state2,
			state3,
			state4
		},
		data() {
			return {
				id: 0,
				orderForm: {
					store:{},
					deliverdetails: [],
					packstation: {},
					loadingproves: [],
					deliverproves: []
				}
			}
		},
		onLoad(opt) {
			this.id = opt.id
			this.getDetails(this.id)
		},
		onPullDownRefresh() {
			this.getDetails(this.id).then(()=>{
				uni.stopPullDownRefresh(); //停止当前页面下拉刷新
			})
		},
		methods: {
			getDetails(id){
				return this.$u.get('/Store/OutOrder/Details?id='+id).then((res)=>{
					this.orderForm = res
				}).catch(res=>{
					uni.showModal({
						title: '提示',
						content: '订单不存在或者错误',
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								// uni.redirectTo({
								// 	url: '/pages/news/news'
								// });
								uni.navigateBack()
							}
						}
					});
				})
			},
			update(){
				this.getDetails(this.id)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.u-color-orange{
		color: $u-color-orange;
	}
	// 宫格展示
	.grid-box {
		background-color: #fff;
		margin: 0 30rpx;
		padding: 30rpx;
		border-radius: 24rpx;
		margin-top: 30rpx;
		box-shadow: $u-color-border-shadow;
		.head-title{
			font-size: 32rpx;
			display: flex;
			justify-content: space-between;
			.more{
				color: $u-color-blue;
			}
		}
		.tips-txt{
			color: $u-tips-color;
			font-size: 24rpx;
		}
	}
	// 订单
	.order {
		// width: 690rpx;
		// background-color: #ffffff;
		// margin: 30rpx auto;
		// border-radius: 30rpx;
		// box-sizing: border-box;
		// padding: 30rpx;
		// font-size: 28rpx;
		// box-shadow: $u-color-border-shadow;
		.top {
			display: flex;
			justify-content: space-between;
			.left {
				display: flex;
				align-items: center;
				.store {
					margin: 0 10rpx;
					font-size: 32rpx;
					font-weight: bold;
				}
			}
			.right {
				color: $u-type-warning-dark;
			}
		}
		.item {
			display: flex;
			margin: 20rpx 0 0;
			justify-content: space-between;
			.left {
				margin-right: 20rpx;
				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 10rpx;
				}
			}
			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}
				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}
				.delivery-time {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;
				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}
				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}
		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;
			.total-price {
				font-size: 32rpx;
				color: $u-color-orange;
			}
		}
		.time{
			font-size: 24rpx;
			margin: 20rpx 0;
			line-height: 40rpx;
		}
		.bottom {
			display: flex;
			margin-top: 40rpx;
			padding: 0 10rpx;
			justify-content: space-between;
			align-items: center;
			.btn {
				line-height: 52rpx;
				width: 160rpx;
				border-radius: 26rpx;
				border: 2rpx solid $u-border-color;
				font-size: 26rpx;
				text-align: center;
				color: $u-type-info-dark;
				padding: 0 10rpx;
			}
			.evaluate {
				color: $u-type-warning-dark;
				border-color: $u-type-warning-dark;
			}
		}
	}
	// 按钮栏
	.navigation {
		display: flex;
		margin-top: 30rpx;
		border: solid 2rpx #f2f2f2;
		background-color: #ffffff;
		position: sticky;
		bottom: 0;
		z-index: 99;
		.right {
			display: flex;
			font-size: 28rpx;
			align-items: center;
			flex: 1;
			justify-content: space-around;
			padding: 20rpx;
			.navbtn{
				width: 100%;
				margin: 0 10rpx;
			}
			.btn {
				line-height: 66rpx;
				padding: 0 30rpx;
				border-radius: 36rpx;
				color: #ffffff;
				margin: 16rpx 0;
			}
			.cancel {
				margin-right: 30rpx;
				color: $u-tips-color;
			}
			.buy {
				background-color: #ff7900;
			}
		}
	}
	// 
	.u-table-box{
		margin: 20rpx 0;
		.green{
			background-color: $u-color-green;
			color: #fff!important;
		}
		.red{
			background-color: $u-color-red;
			color: #fff!important;
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 24rpx;
		.total-price {
			font-size: 32rpx;
			color: $u-color-orange;
		}
	}

	.u-line{
		border-bottom: 1px solid $u-border-color;
		padding-top: 30rpx;
		margin-bottom: 20rpx;
	}
</style>
